package review.interfacedemo;

import com.sun.xml.internal.ws.api.ha.StickyFeature;
public class Computer {
    public void powerOn(){
        System.out.println("开机...");
    }

    public void powerOff(){
        System.out.println("关机...");
    }

    public void useUSBDevice(IUSB usb){
        usb.openUSBDevice();

        // 此处就可以使用该USB设备
        // 向下转型不安全，
        // Mouse mouse = (Mouse) usb;

        if(usb instanceof Mouse){
            Mouse mouse = (Mouse) usb;
            mouse.click();
        }else if(usb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard)usb;
            keyBoard.input();
        }

        usb.closeUSBDevice();
    }
}
